package fr.afcepf.al23.qualite.data;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.ResourceBundle;
import java.util.logging.Logger;

import javax.sql.DataSource;
/**
 * DataSource pour la connection a la BDD 'al23_qualite'.
 * @author stagiaires
 *
 */
public class QualiteDataSource implements DataSource {
    /**
     * Variable correspondant au login de connection a la BDD.
     */
    private static String login;
    /**
     * Variable correspondant au mot de passe de connection a la BDD.
     */
    private static String mdp;
    /**
     * Variable correspondant a l'url de connection a la BDD.
     */
    private static String url;
    static {
        ResourceBundle rb = ResourceBundle.getBundle("qualite");
        try {
            Class.forName(rb.getString("driver"));
            login = rb.getString("login");
            mdp = rb.getString("password");
            url = rb.getString("url");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    public PrintWriter getLogWriter() throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public int getLoginTimeout() throws SQLException {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void setLogWriter(PrintWriter paramArg0) throws SQLException {
        // TODO Auto-generated method stub
    }

    @Override
    public void setLoginTimeout(int paramArg0) throws SQLException {
        // TODO Auto-generated method stub
    }

    @Override
    public boolean isWrapperFor(Class<?> paramArg0) throws SQLException {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public <T> T unwrap(Class<T> paramArg0) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Connection getConnection() throws SQLException {
        Connection cnx = null;
        cnx = DriverManager.getConnection(url, login, mdp);
        return cnx;
    }

    @Override
    public Connection getConnection(String paramArg0, String paramArg1)
            throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }
}
